package com.mq.springcloud.controller

import com.mq.springcloud.entity.CommonResult
import com.mq.springcloud.entity.Payment
import com.mq.springcloud.service.PaymentFeignService
import lombok.extern.slf4j.Slf4j
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RestController
import javax.annotation.Resource


@RestController
@Slf4j
class OrderFeignController {
    @Resource
    private val paymentFeignService: PaymentFeignService? = null

    @GetMapping(value = "/consumer/payment/get/{id}")
    fun getPaymentById(@PathVariable("id") id: Long?): CommonResult<Payment> {
        return paymentFeignService!!.getPaymentById(id)
    }

    /**
     * 暂停几秒方法 超时控制
     * @param
     * @return
     */
    @GetMapping(value = "/consumer/payment/feign/timcout")
    fun paymentFeignTimeout(): String {
        return paymentFeignService!!.paymentFeignTimeout()
    }

    /**
     * 服务超时
     * @param id
     * @return
     */
    @GetMapping(value = "/consumer/payment/feign/paymentInfo_OK/{id}")
    fun paymentInfo_OK(@PathVariable("id") id: Int?): String {
        val s = paymentFeignService!!.paymentInfo_OK(id)
        log.info(s)
        return s
    }

    @GetMapping(value = "/consumer/payment/feign/paymentInfo_Timeout")
    fun paymentInfo_Timeout(@PathVariable("id") id: Long?): String {
        val s = paymentFeignService!!.paymentInfo_Timeout(id)
        log.info(s)
        return s
    }

}
